/**
 * Created by FDG282 on 2017/9/1.
 */
$(function () {

    //IE9下兼容placeholder
    if(navigator.userAgent.indexOf("MSIE 9.0")>0) {
        $('[placeholder]').not("input[type='password']").focus(function () {
            var input = jQuery(this);
            if (input.val() == input.attr('placeholder')) {
                input.val('');
                input.removeClass('placeholder');
            }
        }).blur(function () {
            var input = $(this);
            if (input.val() == '' || input.val() == input.attr('placeholder')) {
                input.addClass('placeholder');
                input.val(input.attr('placeholder'));
            }
        }).blur().parents('form').submit(function () {
            $(this).find('[placeholder]').each(function () {
                var input = $(this);
                if (input.val() == input.attr('placeholder')) {
                    input.val('');
                }
            })
        });
    }

    //登录框切换
    $(".login_list_btn .link-text").on('click',function(){
        $(".user_login_btn .tipinfo").empty();
        var linkindex = $(this).index();
        $(this).addClass("a-active").siblings(".link-text").removeClass("a-active");
        $(".tab1").eq(linkindex).removeClass("hide").addClass("show").siblings(".tab1").addClass("hide");
        $(".user_login_btn .btn").eq(linkindex).removeClass("hide").addClass("show").siblings(".btn").addClass("hide");
    });

    //表单验证
    var reg = /^1(0|1|2|3|4|5|6|7|8|9)\d{9}$/;
    var info = "<span class='info'></span>";
    var inputBg = '<span class="inpdel">x</span>';
    var verificationInfo = {
        validate:{
            errMsg:"此项不能为空"
        },
        emailInfo : {
            errMsg: "邮箱格式不正确"
        },
        phoneInfo: {
            errMsg1: "手机号不能为空",
            errMsg2: "请输入正确的11位手机号"
        },
        passwordInfo: {
            errMsg1: "密码不能为空",
            errMsg2: "6-16位，字母+数字，支持大小写",
            errMsg3: "6-16位，字母+数字，支持大小写"
        },
        verification: {
            errMsg1: "验证码不能为空",
            errMsg2: "验证码格式错误,请重新输入"
        },
        passwordAginInfo: {
            errMsg1:"请重复密码",
            errMsg2: "两次输入的密码不一致"
        },
        winInfo: "注册成功,获得积分,请登陆"
    };

    var master_mobile =  $.cookie('master_mobile');
    if(master_mobile != null && master_mobile != undefined && master_mobile != ''){
        if(reg.test(master_mobile)){
            $('#loginform-mobile').val(master_mobile);
            $('#is_remember').prop('checked',true);
        }
    }
    /*FDG416 2018/1/30 ID482 【商城需求】密码的地方需要输入密码输入可展示的功能 start */
    $('input[type="text"],input[type="password"]').each(function(){
        $(this).focus(function(){
            if($(this).parents(".input-box").find('span.inpdel').length<=0){
                $(this).parents(".input-box").append(inputBg);
                var span_inpdel = $(this).parents(".input-box").find('span.inpdel');
                var that = $(this);
                if($(this).is('.js_password_img')) {
                    $(span_inpdel).html('<img src='+image_bath_url+'/static/pc/image/iconPng/nosee-pc.png>').css('background','#fff').click(function(){
                        if($(that).attr('type') == 'password') {
                            $(that).attr('type','text').parents(".input-box").find('span.inpdel').html('<img src='+image_bath_url+'/static/pc/image/iconPng/see-pc.png>');
                        }else {
                            $(that).attr('type','password').parents(".input-box").find('span.inpdel').html('<img src='+image_bath_url+'/static/pc/image/iconPng/nosee-pc.png>');
                        }
                    });
                }else {
                    $(span_inpdel).on('click',function(){
                        $(this).siblings('input').val('').focus()
                    });
                }
            }
        });
    });
    /*FDG416 2018/1/30 ID482 【商城需求】密码的地方需要输入密码输入可展示的功能 end */
    //登录验证
    $(".form_phone_group, .form_password_group,.img_verification,.phone_verification,.form_passwordsure_group,.input_group,.user_new_passwrod").append(info);
    var wrap1 = $("#form_1"); //密码登录框
    var wrap2 = $("#form_2"); //手机验证码登录框
    var wrap3= $("#register_form"); //注册表单页面
    var wrapFor = $("#forget-form"); //忘记密码页面
    var wrapUpd = $("#updata_form"); //忘记密码页面
    var wrap4 = $("#user-center-form"); //个人中心页面没有绑定微信的表单
    var usernameInput = $(".username_value"); // 个人中心用户姓名
    var emailInput = $(".email_value"); //个人中心邮箱
    var addressInput = $(".address_value");//个人中心详细地址
    var phoneInpt = $(".js_phone");  //整站手机号码
    var passwordInpt = $(".js_password"); //整站密码
    var passwordNewInpt = $(".js_new_password"); //个人中心修改密码
    var passwordSure = $(".js_password_sure"); //整站确认密码
    var imgCode = $(".js_img_code");  //整站图形验证
    var phoneCode = $(".js_phone_code"); //整站手机号短信验证
    var logUseInfo = $(".form_phone_group .info");  //手机号码验证提示信息
    var logPasInfo = $(".form_password_group .info"); //密码验证提示信息
    var passNewInfo = $(".user_new_passwrod .info"); ////个人中心修改密码提示信息
    var pasSureInfo = $(".form_passwordsure_group .info"); //再次密码验证提示信息
    var imgCodeInfo = $(".img_verification .info");  //图形验证提示信息
    var phoneCodeInfo = $(".phone_verification .info"); //手机短信验证码提示信息
    var usernameInfo = $(".user_name .info"); // 个人中心用户姓名提示信息
    var emailInfo = $(".user_email .info"); // 个人中心邮箱提示信息
    var femailInfo = $(".footer-email .info"); // 底部邮箱提示信息
    var addressInfo = $(".user_address_info .info"); // 个人中心详细地址提示信息
    $(".form_input_group .info").empty();
    phoneInpt.keyup(function () {
        var userphone = $(this).val();
        if (userphone <= 0) {
            logUseInfo.html(verificationInfo.phoneInfo.errMsg1).addClass("infoerror");
            empty_info()
            $(this).removeClass("infowaring")
        } else if (!reg.test(userphone)) {
            logUseInfo.html(verificationInfo.phoneInfo.errMsg2).addClass("infoerror");
            empty_info()
            $(this).removeClass("infowaring")
        } else {
            $(".user_login_btn .tipinfo").empty();
            $(".phoneV_btn").attr("disabled",false);
            logUseInfo.html('');
            $(this).addClass("infowaring");
        }
    });
    usernameInput.keyup(function(){
        if($(this).val().length>0){
            usernameInfo.html('');
            $(this).addClass("infowaring");
        }
    });
    addressInput.keyup(function(){
        if($(this).val().length>0){
            addressInfo.html('');
            $(this).addClass("infowaring");
        }
    });
    // 密码输入验证
    function passwrodvalidate(){
        var passwordVa = function(pasInput,pasInfo){
            pasInput.keyup(function () {
                var password = $(this).val();
                if (password.length < 6 || password.length > 16) {
                    pasInfo.html(verificationInfo.passwordInfo.errMsg3).addClass("infoerror");
                    empty_info()
                    $(this).removeClass("infowaring")
                } else if (!(/(?=.*[a-zA-Z])(?=.*[\d])[\w\W]{6,16}/.test(password))) {
                    pasInfo.html(verificationInfo.passwordInfo.errMsg2).addClass("infoerror");
                    empty_info()
                    $(this).removeClass("infowaring")
                }else if(password.length > 16){
                    pasInfo.html(verificationInfo.passwordInfo.errMsg3).addClass("infoerror");
                    empty_info()
                    $(this).removeClass("infowaring")
                }else{
                    pasInfo.html('');
                    $(this).addClass("infowaring")
                }
            });
        };
        passwordVa(passwordInpt,logPasInfo);
        passwordVa(passwordNewInpt,passNewInfo);
    }
    passwrodvalidate();
    //每个必填项输入框提示
    function inputsure(){
        var phoneInpterror = function(wrap,inp,inpInfo){
            wrap.find(inp).focus(function(){
                $Val = wrap.find(inp).val();
                if ($Val.length <= 0) {
                    wrap.find(inp).addClass("inputerror");
                    wrap.find(inpInfo).html(verificationInfo.validate.errMsg).addClass("infoerror");
                    empty_info()
                }
            });
        };
        //密码登录
        phoneInpterror(wrap1,phoneInpt,logUseInfo);
        phoneInpterror(wrap1,passwordInpt,logPasInfo);
        //手机验证登录
        phoneInpterror(wrap2,phoneInpt,logUseInfo);
        phoneInpterror(wrap2,imgCode,imgCodeInfo);
        phoneInpterror(wrap2,phoneCode,phoneCodeInfo);
        //注册
        phoneInpterror(wrap3,phoneInpt,logUseInfo);
        phoneInpterror(wrap3,imgCode,imgCodeInfo);
        phoneInpterror(wrap3,phoneCode,phoneCodeInfo);
        phoneInpterror(wrap3,passwordInpt,logPasInfo);
        phoneInpterror(wrap3,passwordSure,pasSureInfo);
        //忘记密码
        phoneInpterror(wrapFor,phoneInpt,logUseInfo);
        phoneInpterror(wrapFor,imgCode,imgCodeInfo);
        phoneInpterror(wrapFor,phoneCode,phoneCodeInfo);
        phoneInpterror(wrapFor,passwordInpt,logPasInfo);
        phoneInpterror(wrapFor,passwordSure,pasSureInfo);
        // 个人中心资料
        phoneInpterror(wrap4,phoneInpt,logUseInfo);
        phoneInpterror(wrap4,imgCode,imgCodeInfo);
        phoneInpterror(wrap4,phoneCode,phoneCodeInfo);
        phoneInpterror(wrap4,usernameInput,usernameInfo);
        phoneInpterror(wrap4,emailInput,emailInfo);
        phoneInpterror(wrap4,addressInput,addressInfo);

        //修改密码
        phoneInpterror(wrapUpd,passwordNewInpt,passNewInfo);
        phoneInpterror(wrapUpd,passwordInpt,logPasInfo);
        phoneInpterror(wrapUpd,passwordSure,pasSureInfo);
    }

    inputsure();

    imgCode.keyup(function(){
        var imgCodeVal = $(this).val();
        if(imgCodeVal.length>=4){
            imgCodeInfo.html('');
            $(this).addClass("infowaring")
        }else{
            imgCodeInfo.html(verificationInfo.verification.errMsg2).addClass("infoerror");
            empty_info()
            $(this).removeClass("infowaring")
        }
    });
    phoneCode.keyup(function(){
        var phoneCodeVal = $(this).val();
        if(phoneCodeVal.length>=6){
            phoneCodeInfo.html('');
            $(this).addClass("infowaring")
            $(".user_login_btn .tipinfo").empty();
        }else{

            phoneCodeInfo.html(verificationInfo.verification.errMsg2).addClass("infoerror");
            empty_info()
            $(this).removeClass("infowaring")
        }
    });
    emailInput.keyup(function(){
        var emaVal = $(this).val();
        if(emaVal!==""&&(/^(\w)+(\.\w+)*@(\w)+((\.\w{2,3}){1,3})$/.test(emaVal))){
            emailInfo.html('');
            $(this).addClass("infowaring")
        }else{
            emailInfo.html(verificationInfo.emailInfo.errMsg).addClass("infoerror");
            empty_info()
            $(this).removeClass("infowaring")
        }
    });
    //密码登录
    $(".js_login_btn1").click(function () {
        var phoneVal = wrap1.find(phoneInpt).val();
        var passwordVal = wrap1.find(passwordInpt).val();
        var phoneinfoShow = wrap1.find(logUseInfo);
        var phoneinfoBox = wrap1.find(phoneInpt);
        var passwordinfoShow = wrap1.find(logPasInfo);
        var passwordinfoBox = wrap1.find(passwordInpt);
        if(phoneVal == '' ){
            phoneinfoShow.html(verificationInfo.phoneInfo.errMsg1);
            empty_info()
            phoneinfoShow.addClass("infoerror");
            phoneinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(!reg.test(phoneVal)){
            phoneinfoShow.html(verificationInfo.phoneInfo.errMsg2);
            empty_info()
            phoneinfoShow.addClass("infoerror");
            phoneinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(passwordVal == ''){
            passwordinfoShow.html(verificationInfo.passwordInfo.errMsg1);
            empty_info()
            passwordinfoShow.addClass("infoerror");
            passwordinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if (!(/(?=.*[a-zA-Z])(?=.*[\d])[\w\W]{6,16}/.test(passwordVal))){
            passwordinfoShow.html(verificationInfo.passwordInfo.errMsg2);
            empty_info()
            passwordinfoShow.addClass("infoerror");
            passwordinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }

        $.post($('#login-one-form').attr('action'),$('#login-one-form').serialize(),success,'json');
        return false;
        function success(data){
            if(data.code == 200){
                //add by allen.qiang 20170923 登录成功后，记录登录名（网站日志用） start
                $.cookie('user_name',phoneVal,{ path: '/', expires: 30 });
                //add by allen.qiang 20170923 登录成功后，记录登录名（网站日志用） end

                var is_remember = $("input[name='is_remember']:checked").val();
                if(is_remember){
                    $.cookie('master_mobile',phoneVal,{path: '/',expires:10});
                }else{
                    $.cookie('master_mobile', null ,{path: '/'});
                }
                window.location.href=data.url;
            }else{
                $(".tipinfo").text(data.val);
            }
        }
    });
    //手机号码验证登录
    $(".js_login_btn2").click(function(){
        var phoneVal = wrap2.find(phoneInpt).val();
        var imgCodeVal =wrap2.find(imgCode).val();
        var phoneCodeVal = wrap2.find(phoneCode).val();
        var phoneinfoShow = wrap2.find(logUseInfo);
        var phoneinfoBox = wrap2.find(phoneInpt);
        var imgCodeinfoShow = wrap2.find(imgCodeInfo);
        var imgCodeinfoBox = wrap2.find(imgCode);
        var phoneCodeinfoShow = wrap2.find(phoneCodeInfo);
        var phoneCodeinfoBox = wrap1.find(phoneCode);
        if(phoneVal == ""){
            phoneinfoShow.html(verificationInfo.phoneInfo.errMsg1);
            empty_info()
            phoneinfoShow.addClass("infoerror");
            phoneinfoBox.removeClass("infowaring").addClass("inputerror")
        }
        if(!reg.test(phoneVal)){
            phoneinfoShow.html(verificationInfo.phoneInfo.errMsg2);
            empty_info()
            phoneinfoShow.addClass("infoerror");
            phoneinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(imgCodeVal == ""){
            imgCodeinfoShow.html(verificationInfo.verification.errMsg1);
            empty_info()
            imgCodeinfoShow.addClass("infoerror");
            imgCodeinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(phoneCodeVal == ""){
            phoneCodeinfoShow.html(verificationInfo.verification.errMsg1);
            empty_info()
            phoneCodeinfoShow.addClass("infoerror");
            phoneCodeinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }

        $.post($('#login-mobile-form').attr('action'),$('#login-mobile-form').serialize(),success,'json');
        return false;
        function success(data){
            if(data.code == 200){
                //add by allen.qiang 20170923 登录成功后，记录登录名（网站日志用） start
                $.cookie('user_name',phoneVal,{ path: '/', expires: 30 });
                //add by allen.qiang 20170923 登录成功后，记录登录名（网站日志用） end
                window.location.href=data.url;
            }else{
                //验证码首次登录显示注册条款
                if(1023==data.code){
                    $('.is_allowed').removeClass('hide').addClass('show');
                }else{
                    $('#mobileloginform-verifycode-image').trigger('click');
                    $(".tipinfo").text(data.val);
                }


            }
        }

    });
    //倒计时发送短信
    $(".phoneV_btn").click(function(){
        $(this).attr("disabled",true).addClass("btn-active");
        var passwordLength = $(this).parent().parent().parent().find(passwordInpt).length;
        var rePasswordLenth = $(this).parent().parent().parent().find(passwordSure).length;
        if($(this).parents().find(phoneInpt).last().val() == ''){
            $(this).parents().find(phoneInpt).addClass("inputerror");
            $(this).parents().find(phoneInpt).siblings(".info").html(verificationInfo.validate.errMsg).addClass("infoerror");
            empty_info()
            $(this).attr("disabled",false).removeClass("btn-active");
            return false;
        }
        if($(this).parents().find(imgCode).val()==''){
            $(this).parents().find(imgCode).addClass("inputerror");
            $(this).parents().find(imgCode).siblings(".info").html(verificationInfo.validate.errMsg).addClass("infoerror");
            empty_info()
            $(this).attr("disabled",false).removeClass("btn-active");
            return false;
        }
        if(passwordLength > 0){
            var password = $(this).parent().parent().parent().find(passwordInpt).val();
            if(password.length < 6 || password.length > 16){
                $(this).parents().find(passwordInpt).addClass("inputerror");
                $(this).parents().find(passwordInpt).siblings(".info").html(verificationInfo.passwordInfo.errMsg3).addClass("infoerror");
                empty_info()
                $(this).attr("disabled",false).removeClass("btn-active");
                return false;
            }
            if(rePasswordLenth > 0){
                var rePassword = $(this).parent().parent().parent().find(passwordSure).val();
                if(rePassword != password){
                    $(this).parents().find(passwordSure).addClass("inputerror");
                    $(this).parents().find(passwordSure).siblings(".info").html(verificationInfo.passwordAginInfo.errMsg2).addClass("infoerror");
                    empty_info()
                    $(this).attr("disabled",false).removeClass("btn-active");
                    return false;
                }
            }
        }

        //发送短信
        var send_mobile = $(this).parents().find(phoneInpt).last().val();

        var verifyCode = $(this).parents().find(imgCode).val();

        if(!reg.test(send_mobile)){
            $(this).parents().find(phoneInpt).addClass("inputerror");
            $(this).parents().find(phoneInpt).siblings(".info").html('请输入正确的手机号').addClass("infoerror");
            $(this).attr("disabled",false).removeClass("btn-active");
            return false;
        }

        if(verifyCode.length < 4){
            imgCodeInfo.html(verificationInfo.verification.errMsg2).addClass("infoerror");
            empty_info()
            $(this).removeClass("infowaring");
            $(this).attr("disabled",false).removeClass("btn-active");
            return false;
        }

        $.post('/login/mobile-code',{mobile:send_mobile,verifyCode:verifyCode},success,'json');
        return false;
        function success(data){
            var that = $('.phoneV_btn');
            if(data.code == 200){
                var time = 60;
                //连接接口发送短信
                var tim = setInterval(function(){
                    that.text(time+"S后重新发送");
                    time--;
                    if(time==0){
                        clearInterval(tim);
                        that.text("获取手机验证码").attr("disabled",false).removeClass("btn-active");
                    }
                },1000);
            }else{
                $('#captchaform-verifycode-image').trigger('click');
                $(".tipinfo").text(data.val);
                $(that).attr("disabled",false).removeClass("btn-active");
            }
        }
    });
    //重复输入密码
    $(".js_password_sure").keyup(function(){
        var passwordVal = $(this).parents().find(passwordInpt).val();
        var userphonenewVal = $(".js_new_password").val();
        var sureVal =($(this).val()).toString();
        if(sureVal!=="" && sureVal==passwordVal||sureVal==userphonenewVal){
            pasSureInfo.html('');
            $(this).addClass("infowaring")
        }else if(sureVal!=passwordVal||sureVal!=userphonenewVal){
            pasSureInfo.html(verificationInfo.passwordAginInfo.errMsg2);
            empty_info()
            pasSureInfo.addClass("infoerror");
            $(this).removeClass("infowaring")
        }else if(sureVal==""){
            pasSureInfo.html(verificationInfo.passwordAginInfo.errMsg1);
            empty_info()
            pasSureInfo.addClass("infoerror");
            $(this).removeClass("infowaring")
        }
    });
    //注册验证
    $(".js-register-btn").click(function () {
        var phoneVal = wrap3.find(phoneInpt).val();
        var passwordVal = wrap3.find(passwordInpt).val();
        var passwordSureVal = wrap3.find(passwordSure).val();
        var imgCodeVal =wrap3.find(imgCode).val();
        var phoneCodeVal = wrap3.find(phoneCode).val();
        var phoneinfoShow = wrap3.find(logUseInfo);
        var phoneinfoBox = wrap3.find(phoneInpt);
        var passwordinfoShow = wrap3.find(logPasInfo);
        var passwordinfoSureShow = wrap3.find(pasSureInfo);
        var passwordinfoBox = wrap3.find(passwordInpt);
        var passwordinfoSureBox = wrap3.find(passwordSure);
        var imgCodeinfoShow = wrap3.find(imgCodeInfo);
        var imgCodeinfoBox = wrap3.find(imgCode);
        var phoneCodeinfoShow = wrap3.find(phoneCodeInfo);
        var phoneCodeinfoBox = wrap3.find(phoneCode);
        if(phoneVal == ''){
            phoneinfoShow.html(verificationInfo.phoneInfo.errMsg1);
            empty_info()
            phoneinfoShow.addClass("infoerror");
            phoneinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(!reg.test(phoneVal)){
            phoneinfoShow.html(verificationInfo.phoneInfo.errMsg2);
            empty_info()
            phoneinfoShow.addClass("infoerror");
            phoneinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(passwordVal == ''){
            passwordinfoShow.html(verificationInfo.passwordInfo.errMsg1);
            empty_info()
            passwordinfoShow.addClass("infoerror");
            passwordinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if (!(/(?=.*[a-zA-Z])(?=.*[\d])[\w\W]{6,16}/.test(passwordVal))){
            passwordinfoShow.html(verificationInfo.passwordInfo.errMsg2);
            empty_info()
            passwordinfoShow.addClass("infoerror");
            passwordinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(passwordSureVal == ''){
            passwordinfoSureShow.html(verificationInfo.passwordAginInfo.errMsg);
            empty_info()
            passwordinfoSureShow.addClass("infoerror");
            passwordinfoSureBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(imgCodeVal == ""){
            imgCodeinfoShow.html(verificationInfo.verification.errMsg1);
            empty_info()
            imgCodeinfoShow.addClass("infoerror");
            imgCodeinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(phoneCodeVal == ""){
            phoneCodeinfoShow.html(verificationInfo.verification.errMsg1);
            empty_info()
            phoneCodeinfoShow.addClass("infoerror");
            phoneCodeinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }

        var is_check = $('#registerform-isallowed').is(':checked');
        if(is_check === false){
            $(".tipinfo").text('请同意注册条款');
            return false;
        }
        //表单提交
        $.post($('#register-info-form').attr('action'),$('#register-info-form').serialize(),success,'json')
            .beforeSend(function(){
                var loading = layer.msg('正在处理', {
                    icon: 16
                    ,shade: 0.01
                })
            })
            .complete(function() { layer.closeAll() })
            .success(function(data){
                if(data.code == 200){
                    window.location.href = data.url;
                }else{
                    $(".tipinfo").text(data.val);
                }
            })
    });
    //忘记密码
    $(".js_for_submit").click(function () {
        var phoneVal = wrapFor.find(phoneInpt).val();
        var passwordVal = wrapFor.find(passwordInpt).val();
        var passwordSureVal = wrapFor.find(passwordSure).val();
        var imgCodeVal =wrapFor.find(imgCode).val();
        var phoneCodeVal = wrapFor.find(phoneCode).val();
        var phoneinfoShow = wrapFor.find(logUseInfo);
        var phoneinfoBox = wrapFor.find(phoneInpt);
        var passwordinfoShow = wrapFor.find(logPasInfo);
        var passwordSureinfoShow = wrapFor.find(pasSureInfo);
        var passwordinfoBox = wrapFor.find(passwordInpt);
        var passwordSureBox = wrapFor.find(passwordSure);
        var imgCodeinfoShow = wrapFor.find(imgCodeInfo);
        var imgCodeinfoBox = wrapFor.find(imgCode);
        var phoneCodeinfoShow = wrapFor.find(phoneCodeInfo);
        var phoneCodeinfoBox = wrapFor.find(phoneCode);

        if(phoneVal == ''){
            phoneinfoShow.html(verificationInfo.phoneInfo.errMsg1);
            empty_info()
            phoneinfoShow.addClass("infoerror");
            phoneinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(!reg.test(phoneVal)){
            phoneinfoShow.html(verificationInfo.phoneInfo.errMsg2);
            empty_info()
            phoneinfoShow.addClass("infoerror");
            phoneinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(passwordVal == ''){
            passwordinfoShow.html(verificationInfo.passwordInfo.errMsg1);
            empty_info()
            passwordinfoShow.addClass("infoerror");
            passwordinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if (!(/(?=.*[a-zA-Z])(?=.*[\d])[\w\W]{6,16}/.test(passwordVal))){
            passwordinfoShow.html(verificationInfo.passwordInfo.errMsg2);
            empty_info()
            passwordinfoShow.addClass("infoerror");
            passwordinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(passwordSureVal == '' || passwordSureVal != passwordVal){
            passwordSureinfoShow.html(verificationInfo.passwordAginInfo.errMsg2);
            empty_info()
            passwordSureinfoShow.addClass("infoerror");
            passwordSureBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(imgCodeVal == ""){
            imgCodeinfoShow.html(verificationInfo.verification.errMsg1);
            empty_info()
            imgCodeinfoShow.addClass("infoerror");
            imgCodeinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        if(phoneCodeVal == ""){
            phoneCodeinfoShow.html(verificationInfo.verification.errMsg1);
            empty_info()
            phoneCodeinfoShow.addClass("infoerror");
            phoneCodeinfoBox.removeClass("infowaring").addClass("inputerror");
            return false;
        }
        // ajax回传匹配
        /*$(".tips").fadeIn(100).children().text(verificationInfo.winInfo);
         window.location.href='./login.html';*/
        $.post($('#forget-password-form').attr('action'),$('#forget-password-form').serialize(),success,'json');
        return false;
        function success(data){
            if(data.code == 200){
                window.location.href = data.url;
            }else{
                if(1017==data.code){
                    $('.is_allowed').removeClass('hide').addClass('show');
                }else{
                    $(".tipinfo").text(data.val);
                }

            }
        }

    });

    //修改密码
    $(".update_password_btn").click(function () {
        $('#update_password_btn').attr('disabled',true);
        var passwordVal = wrapUpd.find(passwordInpt).val();
        var passwordNewVal = wrapUpd.find(passwordNewInpt).val();
        var passwordSureVal = wrapUpd.find(passwordSure).val();

        var passwordinfoShow = wrapUpd.find(logPasInfo);
        var passNewInfoShow = wrapUpd.find(passNewInfo);
        var passwordSureinfoShow = wrapUpd.find(pasSureInfo);

        var passwordinfoBox = wrapUpd.find(passwordInpt);
        var passwordSureBox = wrapUpd.find(passwordSure);
        var passNewInfoBox = wrapUpd.find(passwordNewInpt);
        if (passwordVal !== "" && passwordNewVal !== "" && passwordSureVal !== "") {
            // ajax回传匹配

            if(passwordNewVal != passwordSureVal){
                $(".tipinfo").text('两次密码输入不一致');
                $('#update_password_btn').attr('disabled',false);
                return false;
            }

            $.post($('#update-password-form').attr('action'),$('#update-password-form').serialize(),success,'json');
            return false;
            function success(data){
                if(data.code == 200){
                    window.location.href = data.url;
                }else{
                    //$('#captchaform-verifycode-image').trigger('click');
                    $(".tipinfo").text(data.val);
                }
            }
        }else if(passwordVal == ""){
            passwordinfoShow.html(verificationInfo.passwordInfo.errMsg1);
            empty_info()
            passwordinfoShow.addClass("infoerror");
            passwordinfoBox.removeClass("infowaring").addClass("inputerror")
        }else if(passwordNewVal==""){
            passNewInfoShow.removeClass("infowaring");
            passNewInfoShow.html(verificationInfo.passwordInfo.errMsg2);
            empty_info()
            passNewInfoBox.addClass("infoerror").addClass("inputerror")
        }else if(passwordSureVal==""){
            passwordSureinfoShow.removeClass("infowaring");
            passwordSureinfoShow.html(verificationInfo.passwordInfo.errMsg2);
            empty_info()
            passwordSureBox.addClass("infoerror").addClass("inputerror")
        }

    });
    //微信快捷登录
    /*   $(".webchat_login").click(function(){
     alert("连接微信接口，跳转微信二维码页面")
     })*/

      //优化
    function empty_info() {
        $(".user_login_btn .tipinfo").empty();
    }
});